package com.taotao.controller;

import com.taotao.pojo.Item;
import com.taotao.pojo.ItemDesc;
import com.taotao.service.ItemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Date;
import java.util.List;

/**
 * ${DESCRIPTION}
 *
 * @author muxiaoyu
 * @create 2017/06/27 14:45
 **/
@Controller
@RequestMapping("item")
public class ItemController {
    @Autowired
    private ItemService itemService;

    @RequestMapping("list")
    @ResponseBody
    public List<Item> queryItemListByPage(Integer page, Integer rows) {
        List<Item> list = itemService.queryItemListByPage(page, rows);
        return list;
    }

    @RequestMapping("add")
    @ResponseBody
    public Boolean queryItemListByPage(Item item, ItemDesc itemDesc) {
        Date date = new Date();
        item.setCreated(date);
        itemDesc.setCreated(date);
        Boolean bool = itemService.addItem(item, itemDesc);
        return bool;
    }
}
